import 'package:flutter/material.dart';
import 'package:flutter_3d_controller/flutter_3d_controller.dart';

class Com3dModel extends StatefulWidget {
  const Com3dModel({super.key});

  @override
  State<Com3dModel> createState() => _Com3dModelState();
}

class _Com3dModelState extends State<Com3dModel> {
  final Flutter3DController controller = Flutter3DController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("模型")),
      body: Flutter3DViewer(
        activeGestureInterceptor: true,
        progressBarColor: Colors.orange,
        enableTouch: true,
        onProgress: (double progressValue) {
          debugPrint('model loading progress : $progressValue');
        },
        onLoad: (String modelAddress) {
          debugPrint('model loaded : $modelAddress');
        },
        onError: (String error) {
          debugPrint('model failed to load : $error');
        },
        controller: controller,
        src: 'assets/models/fox.glb',
      ),
    );
  }
}
